package cn.lger.config;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

/**
 *
 * @author Pro
 */
@Configuration
public class ErrorPageConfig {
    
    @Bean
    public WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> embeddedServletContainerCustomizer(){
        return new MyCustomizer();
    }
    
    private  class MyCustomizer implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory>  {

        @Override
        public void customize(ConfigurableServletWebServerFactory  server) {
            server.addErrorPages(new ErrorPage(HttpStatus.FORBIDDEN, "/403"));
        }

    }

}
